package com.xianzhiOA.interceptor;/**
 * Created by Administrator on 2017/6/9.
 */

import com.xianzhiOA.bean.XzEmp;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 甘汝雷
 * @create 2017-06-09 15:45
 **/
public class InterBackEnd extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        XzEmp empOnline = (XzEmp) request.getSession().getAttribute("userLogin");
        String rPath = request.getServletContext().getContextPath()+"/Login/goLogin";
        //System.out.println(empOnline+"==="+rPath);
        if(empOnline==null){
            response.sendRedirect(rPath);
            return  false;
        }else{
            return true;
        }
    }
}
